package com.wzc.hc.controller;

import com.wzc.hc.entity.po.Shop;
import com.wzc.hc.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
@author:甲方
@date:2025/3/317:07
*/
@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    // 查询
    @GetMapping("/{id}")
    public List<Shop> getAllShops() {
        return shopService.list();
    }



    // 添加
    @PostMapping("/add")
    public String addShop(@RequestBody Shop shop) {
        shopService.save(shop);
        return "添加成功";
    }

    // 删除
    @DeleteMapping("/delete/{id}")
    public String deleteShop(@PathVariable("id") Integer id) {
        shopService.removeById(id);
        return "删除成功";
    }

    // 修改
    @PutMapping("/update")
    public String updateShop(@RequestBody Shop shop) {
        shopService.updateById(shop);
        return "修改成功";
    }

    // 解绑商铺
    @PutMapping("/unbind/{id}")
    public String unbindShop(@PathVariable("id") Integer id) {
        shopService.unbindShop(id);
        return "解绑成功";
    }

    // 出租商铺
    @PutMapping("/rent/{id}")
    public String rentShop(@PathVariable("id") Integer id, @RequestParam("tenantId") Integer tenantId) {
        shopService.rentShop(id, tenantId);
        return "出租成功";
    }
}

